﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DDOS.Game_State;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using DDOS.Content_Management;

namespace DDOS.Objects
{
    class TransitionObject : GameObject
    {
        Room room;
        LevelLayer parent;
        Vector2 player_pos;
        bool boss;

        public TransitionObject(Room rm, LevelLayer p, BoundingObject bo, Vector2 pos, Texture2D t, Vector2 player_spot, bool b)
        {
            room = rm;
            parent = p;
            boundingObject = bo;
            this.texture = t;
            coordinates = pos;
            player_pos = player_spot;
            boss = b;
        }

        public override void CollisionCallback(BoundingObject other, BoundingObject self)
        {
            if (other.parent.GetType() == typeof(Player))
            {
                Activate();
            }
        }

        public void Activate()
        {
            if (boss)
            {
                SoundManager.Instance.Stop();
                SoundManager.Instance.Play(SoundManager.Instance.Boss1, true);
            }
            parent.nextRoom = room;
            parent.curRoom.Deactivate();
            parent.nextRoom.setPlayerPos(player_pos);
            parent.nextRoom.Activate();
        }

        public override void InitializeComponents()
        {
            //Nothing to initialize here, this and the other empty functions
            //are only here to fullfil C#'s requirement to override abstract
        }

        public override void Update(GameTime game_time)
        {
            //We don't do anythig here, transitions don't move.
        }

        public override void Draw()
        {
            ScreenManager.Instance.CurrentSpriteBatch.Draw(texture, coordinates, Color.White);
        }
    }
}
